home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / wb-tools / sysi2 / sysi2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-12  |  18.0 KB  |  767 lines

  1. #include <proto/exec.h>
  2. #include <proto/intuition.h>
  3. #include <proto/utility.h>
  4. #include <proto/graphics.h>
  5. #include <graphics/gfxmacros.h>
  6. #include <dos.h>
  7. #include <graphics/gfx.h>
  8.  
  9. #include <stdio.h>
  10. #include <exec/types.h>
  11. #include <utility/tagitem.h>
  12. #include <intuition/intuition.h>
  13. #include <intuition/screens.h>
  14. #include <intuition/gadgetclass.h> /* contains IDs for gadget attributes */
  15. #include <intuition/icclass.h>     /* contains ICA_MAP, ICA_TARGET       */
  16. #include <intuition/imageclass.h>
  17. #include <math.h>
  18. #include <debug.h>
  19.  
  20. UBYTE *vers = "\0$VER: SysI2 1.0";
  21. struct BitMap *TmpRasBM;
  22. struct SignalSemaphore TRBMSem;
  23.  
  24. typedef union MsgUnion
  25. {
  26.   ULONG  MethodID;
  27.   struct opSet    opSet;
  28.   struct opUpdate opUpdate;
  29.   struct opGet    opGet;
  30.   struct impDraw  impDraw;
  31. } *Msgs;
  32.  
  33. void FillArea(struct RastPort *RP,ULONG Points, ...);
  34. ULONG __saveds __asm Dispatcher(register __a0 Class *C, register __a2 struct Image *O, register __a1 Msgs M );
  35. ULONG RenderImage(Class *C, struct Image *Image, Msgs M);
  36. void DrawBack(struct RastPort *Shine, 
  37.               struct RastPort *Shadow,
  38.               struct RastPort *Fill,
  39.               WORD X1,
  40.               WORD Y1,
  41.               WORD X2,
  42.               WORD Y2);
  43. void MyRectFill(struct RastPort *RP,
  44.               WORD X1,
  45.               WORD Y1,
  46.               WORD X2,
  47.               WORD Y2);
  48.  
  49. struct IntuitionBase *IntuitionBase;
  50. struct Window *w;
  51. struct IntuiMessage *msg;
  52.  
  53. #define NUM_IMAGES 12
  54.  
  55. ULONG sysnum[]=
  56. {
  57.   ZOOMIMAGE,
  58.   SIZEIMAGE,
  59.   CLOSEIMAGE,    
  60.   SDEPTHIMAGE,    
  61.   LEFTIMAGE,
  62.   UPIMAGE,
  63.   RIGHTIMAGE,
  64.   DOWNIMAGE,
  65.   CHECKIMAGE,
  66.   MXIMAGE,
  67.   MENUCHECK,
  68.   AMIGAKEY
  69. };
  70.  
  71. struct SysIData
  72. {
  73.   ULONG si_Which;
  74.   struct DrawInfo *si_DrawInfo;
  75. };
  76.  
  77. //#define DEMO
  78.  
  79.  
  80. #ifdef DEMO
  81. #define MYNAME "testmyiclass"
  82. #define SUPERNAME "sysiclass"
  83. #else
  84. #define MYNAME "sysiclass"
  85. #define SUPERNAME "oldsysiclass"
  86. #endif
  87.  
  88. void install(void);
  89. void test(void);
  90.  
  91. void main(void)
  92. {
  93.   if (IntuitionBase = OpenLibrary((UBYTE *)"intuition.library", 39L))
  94.   {
  95.     InitSemaphore(&TRBMSem);
  96.     if(TmpRasBM=AllocBitMap(100,100,1,BMF_DISPLAYABLE,0))
  97.     {
  98. #ifndef DEMO
  99.       install();
  100. #else
  101.       test();
  102. #endif
  103.       FreeBitMap(TmpRasBM);
  104.     }    
  105.  
  106.     CloseLibrary(IntuitionBase);
  107.   }
  108. }
  109.  
  110. #ifndef DEMO
  111. void install(void)
  112. {
  113.   Class *cl,*syscl;
  114.   STRPTR oldsysname;
  115.  
  116.    if(cl=MakeClass(0,(UBYTE *)"sysiclass",NULL,0,0))
  117.   {
  118.     syscl=cl->cl_Super;
  119.     RemoveClass(syscl);
  120.     oldsysname=syscl->cl_ID;
  121.     syscl->cl_ID=(UBYTE *)"oldsysiclass";
  122.     AddClass(syscl);
  123.     FreeClass(cl);
  124.     if(cl=MakeClass((UBYTE *)"sysiclass",(UBYTE *)"oldsysiclass",NULL,sizeof(struct SysIData),0))
  125.     {
  126.       cl->cl_Dispatcher.h_Entry=Dispatcher;
  127.       AddClass(cl);
  128.       while(1) // endless loop
  129.         Wait(0);
  130.       FreeClass(cl);
  131.     }
  132.     syscl->cl_ID=oldsysname;
  133.   }
  134. }
  135. #else
  136. void test(void)
  137. {
  138.   Class *cl;
  139.   Object *o[NUM_IMAGES];
  140.   struct DrawInfo *di;
  141.   struct Window *w;
  142.   WORD width=32, height=32,l,done=0;
  143.   LONG state=0;
  144.  
  145.  
  146.   if(cl=MakeClass((UBYTE *)"testiclass",(UBYTE *)"sysiclass",NULL,sizeof(struct SysIData),0))
  147.   {
  148.     cl->cl_Dispatcher.h_Entry=Dispatcher;
  149.     AddClass(cl);
  150.     
  151.     
  152.     if (w = OpenWindowTags(NULL,
  153.                       WA_Flags,       WFLG_CLOSEGADGET|WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_SIZEBBOTTOM,
  154.                       WA_IDCMP,       IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_NEWSIZE,
  155.                       WA_MinWidth,    100,
  156.                       WA_MinHeight,   100,
  157.                       WA_MaxWidth,    32000,
  158.                       WA_MaxHeight,   32000,
  159.                       WA_Width      ,32000,
  160.                       WA_Height     ,32000,
  161.                       WA_AutoAdjust, 1,
  162.                       TAG_END))
  163.     {                 
  164.       if(di=GetScreenDrawInfo(w->WScreen))
  165.       {
  166.         
  167.         for(l=0;l<NUM_IMAGES;l++)
  168.         {
  169.           o[l] = (struct Image *)NewObject(cl, NULL,
  170.                           IA_Top      ,(w->BorderTop) + 5,  
  171.                           IA_Left     ,(w->BorderLeft) + 5 + l * (width+10),
  172.                           IA_Width    ,width,
  173.                           IA_Height   ,height,
  174.                           SYSIA_Which ,sysnum[l],
  175.                           SYSIA_DrawInfo,di,
  176.                           TAG_END);
  177.         }
  178.         while (done == FALSE)    
  179.         {                        
  180.             
  181.           for(l=0;l<NUM_IMAGES;l++)
  182.           {
  183.             
  184.             SetAttrs(o[l],IA_Top      ,(w->BorderTop) + 5,  
  185.                           IA_Left     ,(w->BorderLeft) + 5 + l * (width+10),
  186.                           IA_Width    ,width,
  187.                           IA_Height   ,height,
  188.                           TAG_DONE);
  189.             
  190.             DrawImageState(w->RPort,(struct Image *)o[l],(w->BorderLeft) + 5L + l * (width+10),(w->BorderTop) + 5+ l *(height + 10),state ,di);
  191.           }
  192.             
  193.             
  194.           state++;
  195.           if(state>8)
  196.           {
  197.             state=0;
  198.             width++;
  199.             height++;
  200.           }
  201.             
  202.           WaitPort((struct MsgPort *)w->UserPort);
  203.           while (msg = (struct IntuiMessage *)GetMsg((struct MsgPort *)w->UserPort))
  204.           {
  205.             if (msg->Class == IDCMP_CLOSEWINDOW)
  206.               done = TRUE;
  207.             ReplyMsg((struct Message *)msg);
  208.           }
  209.         }
  210.         for(l=0;l<NUM_IMAGES;l++)
  211.         DisposeObject(o[l]);
  212.         FreeScreenDrawInfo(w->WScreen,di);
  213.       }
  214.       CloseWindow(w);
  215.     }
  216.     FreeClass(cl);
  217.   }
  218. }
  219. #endif
  220.  
  221.  
  222. ULONG __saveds __asm Dispatcher(register __a0 Class *C, register __a2 struct Image *O, register __a1 Msgs M )
  223. {
  224.   struct SysIData *sidata;
  225.   struct Image *object;
  226.   ULONG retval=0;
  227. /*
  228.   WORD width,height;
  229.  
  230.  
  231.   Point sizetable[]=
  232.   {
  233.     18,-1,24,-1,24,-1,
  234.     18,-1,18,-1,24,-1,
  235.     13,11,19,13,19,13,
  236.     15,-1,20,-1,20,-1,
  237.     -1,-1,-1,-1,-1,-1,
  238.     17,-1,23,-1,23,-1,
  239.     -1,-1,-1,-1,-1,-1,
  240.     -1,-1,-1,-1,-1,-1,
  241.     -1,-1,-1,-1,-1,-1,
  242.     -1,-1,-1,-1,-1,-1,
  243.     16,11,19,13,19,13,
  244.     16,11,19,13,19,13,
  245.     16,11,19,13,19,13,
  246.     16,11,19,13,19,13,
  247.   };
  248. */
  249.   switch(M->MethodID)
  250.   {
  251.     case OM_NEW:
  252.       {
  253.         ULONG which,size;
  254.         struct DrawInfo *di;
  255.         
  256.         di=(struct DrawInfo *)GetTagData(SYSIA_DrawInfo,0, M->opSet.ops_AttrList);
  257.         
  258.         if(di)
  259.         {
  260.           if(object=(struct Image *)DoSuperMethodA(C,(Object *)O,(Msg)M))
  261.           {
  262.  
  263.             which =GetTagData(SYSIA_Which,   0, M->opSet.ops_AttrList);
  264.             size  =GetTagData(SYSIA_Size,   2,M->opSet.ops_AttrList);
  265.  
  266. /*
  267.             switch(which)
  268.             {
  269.               case SIZEIMAGE:
  270.               case UPIMAGE:
  271.               case DOWNIMAGE:
  272.               case LEFTIMAGE:
  273.               case RIGHTIMAGE:
  274.                 width=  sizetable[which*3+size].x;
  275.                 height= sizetable[which*3+size].y;
  276.             
  277.                 if(width>-1)
  278.                   object->Width=width;
  279.                 if(height>-1)
  280.                   object->Height=height;
  281.                 
  282.                 object->Height=GetTagData(IA_Height,object->Height,M->opSet.ops_AttrList);
  283.                 object->Width =width;//(object->Height*di->dri_Resolution.Y)/di->dri_Resolution.X;
  284.             }*/
  285.  
  286.             sidata=INST_DATA(C, object);
  287.             //kprintf("sidata - %8lx\n",sidata);
  288.             sidata->si_Which   =which;
  289.             sidata->si_DrawInfo=di;
  290.  
  291. /*            
  292.             switch(which)
  293.             {
  294.               case SIZEIMAGE:
  295.               case LEFTIMAGE:
  296.               case UPIMAGE:
  297.               case RIGHTIMAGE:
  298.               case DOWNIMAGE:
  299.                 object->Width=(object->Height*di->dri_Resolution.X)/di->dri_Resolution.Y;
  300.                 DoSuperMethod(C,object,OM_UPDATE,
  301.                       IA_Width,object->Width,
  302.                       TAG_DONE);
  303.               break;
  304.             }
  305.             */
  306.           }
  307.           //kprintf("di - %8lx\n",di);
  308.           //kprintf("which - %8lx\n",which);
  309.           retval=(ULONG)object;
  310.         }
  311.       }
  312.       break;
  313.  
  314.     case IM_DRAWFRAME:
  315.     case IM_DRAW:
  316.       //kprintf("IM_DRAW\n");
  317.       retval=RenderImage(C,O,(Msgs)M);
  318.       break;
  319. /*      
  320.     case OM_DISPOSE:
  321.       sidata=INST_DATA(C, object);
  322.       retval=DoSuperMethodA(C,(Object *)O,(Msg)M);
  323.       break;
  324.   */    
  325.     default:
  326.       retval=DoSuperMethodA(C,(Object *)O,(Msg)M);
  327.       break;
  328.   }
  329.   return(retval);
  330. }
  331.  
  332. #define SI2_INACTIVE    1<<0
  333. #define SI2_SELECTED    1<<1
  334. #define SI2_DISABLED    1<<2
  335.  
  336. ULONG RenderImage(Class *C, struct Image *Image, Msgs M)
  337. {
  338.   struct DrawInfo *di;
  339.   struct SysIData *sidata;
  340.   struct RastPort *rp,shinerp,shadowrp,backrp,fillrp,
  341.                   *bshinerp,*bshadowrp,*bfillrp,
  342.                   *ishinerp,*ishadowrp,*ibackrp;
  343.   LONG state;
  344.   LONG left,top,right,bottom,width,height;
  345.   ULONG l,shine,shadow,back,fill;
  346.   WORD w[11],h[11];
  347.   ULONG att[]=
  348.   {
  349.     0,
  350.     SI2_SELECTED,
  351.     SI2_DISABLED,
  352.     0,
  353.     0,
  354.     SI2_INACTIVE,
  355.     SI2_INACTIVE | SI2_SELECTED,
  356.     SI2_INACTIVE | SI2_DISABLED,
  357.     SI2_SELECTED | SI2_DISABLED,
  358.   };
  359.   ULONG rv=1;
  360.  
  361.   geta4();
  362.      
  363.   sidata=INST_DATA(C, Image);
  364.  
  365.   if(!(di=M->impDraw.imp_DrInfo))
  366.     di=sidata->si_DrawInfo;
  367.  
  368.   shine =di->dri_Pens[SHINEPEN];
  369.   shadow=di->dri_Pens[SHADOWPEN];
  370.   back  =di->dri_Pens[BACKGROUNDPEN];
  371.   fill  =di->dri_Pens[FILLPEN];
  372.   
  373.   rp=M->impDraw.imp_RPort;
  374.   shinerp =*rp;
  375.   
  376.   SetDrMd(&shinerp,JAM1);
  377.   SetDrPt(&shinerp,~0);
  378.   
  379.   shadowrp=shinerp;
  380.   fillrp  =shinerp;
  381.   backrp  =fillrp;
  382.   
  383.   SetAPen(&shinerp,shine);
  384.   SetAPen(&shadowrp,shadow);
  385.   SetAPen(&backrp,back);
  386.   SetAPen(&fillrp,fill);
  387.  
  388.   left=M->impDraw.imp_Offset.X;
  389.   top =M->impDraw.imp_Offset.Y;
  390.   
  391.   if(M->MethodID==IM_DRAWFRAME)
  392.   {
  393.     width =M->impDraw.imp_Dimensions.Width;
  394.     height=M->impDraw.imp_Dimensions.Height;
  395.   }
  396.   else
  397.   {
  398.     width =Image->Width;
  399.     height=Image->Height;
  400.   }
  401.   
  402.   switch(sidata->si_Which)
  403.   {
  404.     case DEPTHIMAGE:
  405.     case ZOOMIMAGE:
  406.       width--;
  407.   }
  408.  
  409.   right =left + width  -1;
  410.   bottom=top  + height -1;
  411.   
  412.   for(l=0;l<6;l++)
  413.   {
  414.     LONG x,y;
  415.     
  416.     x=(width  * l)/10;
  417.     y=(height * l)/10;
  418.     w[l]=x + left;
  419.     h[l]=y + top;
  420.     w[10-l]=right-x;
  421.     h[10-l]=bottom-y;
  422.   }
  423.   
  424.   ////kprintf("Drawing %ld %ld %ld %ld\n  sidata %8lx\n  DI %8lx  Which %8lx\n",left,top,width,height,sidata,sidata->si_DrawInfo,sidata->si_Which);
  425.   
  426.   /*** Draw Frame ***/
  427.   SetDrMd(rp,JAM1);
  428.   SetDrPt(rp,~0);
  429.  
  430.   state=att[M->impDraw.imp_State];
  431.  
  432.   //kprintf("state - %ld\n",state);
  433.   
  434.   if(state & SI2_SELECTED)
  435.   {
  436.     bshinerp  =&shadowrp;
  437.     bshadowrp =&shinerp;
  438.   }
  439.   else
  440.   {
  441.     bshinerp  =&shinerp;
  442.     bshadowrp =&shadowrp;
  443.   }
  444.   
  445.   ishadowrp =&shadowrp;
  446.   ibackrp   =&backrp;
  447.   
  448.   if(state & (SI2_INACTIVE))
  449.   {
  450.     bfillrp=&backrp;
  451.     ishinerp=&shinerp; // <---------------
  452.   }
  453.   else
  454.   {
  455.     bfillrp=&fillrp;
  456.     ishinerp=&shinerp;
  457.   }
  458.   
  459.   /*
  460.   if(sidata->si_Which<CHECKIMAGE)
  461.   {
  462.     MyRectFill(bfillrp,left,top,right,bottom);
  463.     Move(bshadowrp,right,top);
  464.     Draw(bshadowrp,right,bottom);
  465.     Draw(bshadowrp,left,bottom);
  466.     
  467.     Move(bshinerp,left,bottom);
  468.     Draw(bshinerp,left,top);
  469.     Draw(bshinerp,right,top);
  470.   }
  471.   */
  472.   
  473.   switch(sidata->si_Which)
  474.   {
  475.     case SDEPTHIMAGE:
  476.       bfillrp=&backrp;
  477.     case DEPTHIMAGE:
  478.       DrawBack(bshinerp,bshadowrp,bfillrp,left,top,right,bottom);
  479.     
  480.       Move(ishadowrp,w[2],h[6]);
  481.         Draw(ishadowrp,w[2],h[2]);
  482.         Draw(ishadowrp,w[6],h[2]);
  483.       Move(ishadowrp,w[6],h[4]);
  484.         Draw(ishadowrp,w[8],h[4]);
  485.       Move(ishadowrp,w[4],h[6]);
  486.         Draw(ishadowrp,w[4],h[8]);
  487.       
  488.       Move(ishinerp,w[6],h[2]+1);
  489.         Draw(ishinerp,w[6],h[4]);
  490.       Move(ishinerp,w[2]+1,h[6]);
  491.         Draw(ishinerp,w[4],h[6]);
  492.       Move(ishinerp,w[4]+1,h[8]);
  493.         Draw(ishinerp,w[8],h[8]);
  494.         Draw(ishinerp,w[8],h[4]+1);
  495.       
  496.       MyRectFill(ibackrp,w[2]+1,h[2]+1,w[6]-1,h[6]-1);
  497.       MyRectFill(ibackrp,w[4]+1,h[4]+1,w[8]-1,h[8]-1);
  498.  
  499. //      MyRectFill(ishinerp,w[4]+1,h[4]+1,w[8]-2,h[8]-2);
  500.  
  501.       Move(&shadowrp,left-1,top+1);
  502.         Draw(&shadowrp,left-1,bottom);
  503.       break;
  504.     case ZOOMIMAGE:
  505.       DrawBack(bshinerp,bshadowrp,bfillrp,left,top,right,bottom);
  506.     
  507.       Move(ishinerp,w[8],h[2]);
  508.         Draw(ishinerp,w[8],h[8]);
  509.         Draw(ishinerp,w[2],h[8]);
  510.       
  511.       Move(ishadowrp,w[2],h[8]);
  512.         Draw(ishadowrp,w[2],h[2]);
  513.         Draw(ishadowrp,w[8],h[2]);
  514.       
  515.       MyRectFill(ibackrp  ,w[2]+1,h[2]+1,w[8]-1,h[8]-1);
  516.       MyRectFill(ishadowrp,w[2]+2,h[2]+2,w[4]+2,h[4]+2);
  517.       
  518.       Move(&shadowrp,left-1,top+1);
  519.         Draw(&shadowrp,left-1,bottom);
  520.       break;
  521.     case SIZEIMAGE:
  522.       DrawBack(bshinerp,bshadowrp,bfillrp,left,top,right,bottom);
  523.  
  524.       FillArea(&backrp,3,w[8],h[2],
  525.                          w[8],h[8],
  526.                          w[2],h[8]);
  527.       Move(ishinerp,w[8],h[2]);
  528.         Draw(ishinerp,w[8],h[8]);
  529.         Draw(ishinerp,w[2],h[8]);
  530.       
  531.       Move(ishadowrp,w[2],h[8]);
  532.         Draw(ishadowrp,w[8],h[2]);
  533.       break;
  534.     case CLOSEIMAGE:
  535.       DrawBack(bshinerp,bshadowrp,bfillrp,left,top,right,bottom);      
  536.  
  537.       Move(ishadowrp,w[2],h[6]-1);
  538.         Draw(ishadowrp,w[2],h[4]+1);
  539.       Move(ishadowrp,w[2]+1,h[4]);
  540.         Draw(ishadowrp,w[8]-1,h[4]);
  541.       
  542.       Move(ishinerp,w[8],h[4]+1);
  543.         Draw(ishinerp,w[8],h[6]-1);
  544.       Move(ishinerp,w[8]-1,h[6]);
  545.         Draw(ishinerp,w[2]+1,h[6]);
  546.       
  547.       MyRectFill(ibackrp,w[2]+1,h[4]+1,w[8]-1,h[6]-1);
  548.       
  549.       Move(&shinerp,right+1,top+1);
  550.         Draw(&shinerp,right+1,bottom);
  551.       break;
  552.     case LEFTIMAGE:
  553.       DrawBack(bshinerp,bshadowrp,bfillrp,left,top,right,bottom);
  554.       
  555.       FillArea(&backrp,3,w[7],h[2],
  556.                          w[7],h[8],
  557.                          w[2],h[5]);
  558.       
  559.       Move(ishinerp,w[7],h[2]);
  560.         Draw(ishinerp,w[7],h[8]);
  561.         Draw(ishinerp,w[2],h[5]);
  562.       
  563.       Move(ishadowrp,w[2],h[5]);
  564.         Draw(ishadowrp,w[7],h[2]);
  565.       break;
  566.     case UPIMAGE:
  567.       DrawBack(bshinerp,bshadowrp,bfillrp,left,top,right,bottom);
  568.       
  569.       FillArea(&backrp,3,w[2],h[7],
  570.                          w[5],h[2],
  571.                          w[8],h[7]);
  572.       
  573.       Move(ishinerp,w[8],h[7]);
  574.         Draw(ishinerp,w[2],h[7]);
  575.       
  576.       Move(ishadowrp,w[2],h[7]);
  577.         Draw(ishadowrp,w[5],h[2]);
  578.         Draw(ishadowrp,w[8],h[7]);
  579.       break;
  580.     case RIGHTIMAGE:
  581.       DrawBack(bshinerp,bshadowrp,bfillrp,left,top,right,bottom);
  582.  
  583.       FillArea(&backrp,3,w[3],h[2],
  584.                          w[3],h[8],
  585.                          w[8],h[5]);
  586.       
  587.       Move(ishinerp,w[8],h[5]);
  588.         Draw(ishinerp,w[3],h[8]);
  589.         
  590.       Move(ishadowrp,w[3],h[8]);
  591.         Draw(ishadowrp,w[3],h[2]);
  592.         Draw(ishadowrp,w[8],h[5]);
  593.       
  594.       break;
  595.     case DOWNIMAGE:
  596.       DrawBack(bshinerp,bshadowrp,bfillrp,left,top,right,bottom);      
  597.      
  598.       FillArea(&backrp,3,w[2],h[3],
  599.                          w[8],h[3],
  600.                          w[5],h[8]);
  601.      
  602.      
  603.       Move(ishinerp,w[8],h[3]);
  604.         Draw(ishinerp,w[5],h[8]);
  605.         Draw(ishinerp,w[2],h[3]);
  606.       
  607.       Move(ishadowrp,w[2],h[3]);
  608.         Draw(ishadowrp,w[8],h[3]);
  609.       break;
  610.     //case MENUCHECK:
  611.     /*
  612.     case CHECKIMAGE:
  613.       DrawBack(ishinerp,ishadowrp,ibackrp,left,top,right,bottom);
  614.       if(state & SI2_SELECTED)
  615.       {
  616.         Move(ishinerp,w[9],h[2]);
  617.           Draw(ishinerp,w[3],h[8]);
  618.           Draw(ishinerp,w[1],h[6]);
  619.         Move(ishadowrp,w[1],h[6]);
  620.           Draw(ishadowrp,w[2],h[6]);
  621.           Draw(ishadowrp,w[3],h[7]);
  622.           Draw(ishadowrp,w[8],h[2]);
  623.           Draw(ishadowrp,w[9],h[2]);
  624.       }
  625.       break;
  626.     */
  627.     case MXIMAGE:
  628.       {
  629.         struct RastPort *mxrp;
  630.         
  631.         mxrp=&backrp;
  632.         if(state & SI2_SELECTED)
  633.           mxrp=&fillrp;
  634.         
  635.         FillArea(mxrp,4,w[2],h[5],
  636.                          w[5],h[2],
  637.                          w[8],h[5],
  638.                          w[5],h[8]);
  639.       }
  640.       Move(bshadowrp,w[0],h[5]);
  641.         Draw(bshadowrp,w[5],h[10]);
  642.         Draw(bshadowrp,w[10],h[5]);
  643.       Move(bshinerp,w[0],h[5]);
  644.         Draw(bshinerp,w[5],h[0]);
  645.         Draw(bshinerp,w[10],h[5]);
  646.       
  647.       
  648.       
  649.       /*
  650.       Move(bshadowrp,w[9],h[2]);
  651.         Draw(bshadowrp,w[10],h[4]);
  652.         Draw(bshadowrp,w[10],h[6]);
  653.         Draw(bshadowrp,w[9],h[8]);
  654.         Draw(bshadowrp,w[8],h[9]);
  655.         Draw(bshadowrp,w[6],h[10]);
  656.         Draw(bshadowrp,w[4],h[10]);
  657.         Draw(bshadowrp,w[2],h[9]);
  658.         Draw(bshadowrp,w[1],h[8]);
  659.       Move(bshinerp,w[1],h[8]);
  660.         Draw(bshinerp,w[0],h[6]);
  661.         Draw(bshinerp,w[0],h[4]);
  662.         Draw(bshinerp,w[1],h[2]);
  663.         Draw(bshinerp,w[2],h[1]);
  664.         Draw(bshinerp,w[4],h[0]);
  665.         Draw(bshinerp,w[6],h[0]);
  666.         Draw(bshinerp,w[8],h[1]);
  667.         Draw(bshinerp,w[9],h[2]); 
  668.         */
  669.       break;
  670.     default:
  671.       rv=DoSuperMethodA(C,(Object *)Image,(Msg)M);
  672.   }
  673.   return(rv);
  674. }
  675.  
  676. void DrawBack(struct RastPort *Shine, 
  677.               struct RastPort *Shadow,
  678.               struct RastPort *Fill,
  679.               WORD X1,
  680.               WORD Y1,
  681.               WORD X2,
  682.               WORD Y2)
  683. {
  684.   MyRectFill(Fill,X1,Y1,X2,Y2);
  685.   Move(Shadow,X2,Y1);
  686.   Draw(Shadow,X2,Y2);
  687.   Draw(Shadow,X1,Y2);
  688.     
  689.   Move(Shine,X1,Y2);
  690.   Draw(Shine,X1,Y1);
  691.   Draw(Shine,X2,Y1);
  692. }
  693.  
  694. struct Point32
  695. {
  696.   LONG X,Y;
  697. };
  698.  
  699. void FillArea(struct RastPort *RP,ULONG Points, ...)
  700. {
  701.   struct AreaInfo ai={0},*oldai;
  702.   __aligned UBYTE ab[5*5];
  703.  
  704.   struct TmpRas tr,*oldtr;
  705.  
  706.   WORD minx,maxx,miny,maxy,sx,sy;
  707.   LONG l,points,*pntr;
  708.   struct Point32 *p;
  709.  
  710.   pntr  = &Points;
  711.   points= *pntr;
  712.  
  713. //  kprintf("--%8lx\n",pntr);
  714.  
  715.   pntr++;
  716.   p=pntr;
  717.   
  718.   minx=miny= 32000;
  719.   maxx=maxy=-32000;
  720.   
  721.  
  722.  
  723.   for(l=0;l<points;l++)
  724.   {
  725.     minx=min(minx,p[l].X);
  726.     miny=min(miny,p[l].Y);
  727.     maxx=max(maxx,p[l].X);
  728.     maxy=max(maxy,p[l].Y);
  729.   }
  730.   sx=maxx-minx;
  731.   sy=maxy-miny;
  732.   
  733.   if( sx<100 && sy<100 )
  734.   {
  735.     ObtainSemaphore(&TRBMSem);
  736.     tr.RasPtr=TmpRasBM->Planes[0];
  737.     tr.Size=TmpRasBM->BytesPerRow * TmpRasBM->Rows;
  738.     oldtr=RP->TmpRas;
  739.     oldai=RP->AreaInfo;
  740.     RP->TmpRas=&tr;
  741.     RP->AreaInfo=&ai;
  742.     InitArea(&ai,ab,5);
  743.     AreaMove(RP,p[0].X,p[0].Y);
  744.     for(l=1;l<points;l++)
  745.     {
  746. //      printf("%ld  %ld\n",p[l].X,p[l].Y);
  747.       AreaDraw(RP,p[l].X,p[l].Y);
  748.     }
  749.     AreaEnd(RP);
  750.     RP->TmpRas=oldtr;
  751.     RP->AreaInfo=oldai;
  752.     WaitBlit();
  753.     ReleaseSemaphore(&TRBMSem);
  754.   }
  755. }
  756.   
  757.  
  758. void MyRectFill(struct RastPort *RP,
  759.               WORD X1,
  760.               WORD Y1,
  761.               WORD X2,
  762.               WORD Y2)
  763. {
  764.   if(X2>=X1 && Y2>=Y1 && X1>=0 && Y1>=0)
  765.     RectFill(RP,X1,Y1,X2,Y2);
  766. }
  767.